var test = 2

$(function () {
  $('#menubtn').click(function(){
    $("#navBar").css({
      backgroundColor:"white",
    })
  })
})


function mHttp() {
  var m_time = $('#m_time').val()
  var d_time = $('#d_time').val()
  var platform = $('#platform').val()
  var intelligent_name = $('#intelligent_name').val()
  var intelligent_phone = $('#intelligent_phone').val()
  var wechat = $('#wechat').val()
  var category = $('#category').val()
  var intelligent = $('#intelligent').val()
  var intelligent_text = $('#intelligent_text').val()
  var intelligent_image = $('#intelligent_image').val()
  var intelligent_media = $('#intelligent_media').val()
  var intelligent_video = $('#intelligent_video').val()
  var intelligent_explain = $('#intelligent_explain').val()
  var register = $('#register').val()
  var url =  host + '/medium?intelligent_text=' + intelligent_text+ '&intelligent_image=' + intelligent_image + '&intelligent_media=' + intelligent_media + '&intelligent_video=' + intelligent_video + '&intelligent_explain=' + intelligent_explain  + '&register=' + register
  let httpRequest = new XMLHttpRequest();//第一步：创建需要的对象
  httpRequest.open('POST', url, true); //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
  // httpRequest.open('GET', url, true); //第二步：打开连接/***发送json格式文件必须设置请求头 ；如下 - */
  httpRequest.setRequestHeader("Access-Control-Allow-Credentials", true);//设置请求头 注：post方式必须设置请求头（在建立连接后设置请求头）var obj = { name: 'zhansgan', age: 18 };
  httpRequest.setRequestHeader("Access-Control-Allow-Origin", "*");
  httpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;");
  var data = 'm_time='+ m_time + '&d_time=' + d_time + '&platform=' + platform + '&intelligent_name=' + intelligent_name + '&intelligent_phone=' + intelligent_phone + '&wechat=' + wechat + '&category=' + category +  '&intelligent=' + intelligent + '&intelligent_text=' + intelligent_text+ '&intelligent_image=' + intelligent_image + '&intelligent_media=' + intelligent_media + '&intelligent_video=' + intelligent_video + '&intelligent_explain=' + intelligent_explain  + '&register=' + register
  httpRequest.send(data);//发送请求 将json写入send中
  /**
   * 获取数据后的处理程序
   */
  httpRequest.onreadystatechange = function () {//请求后的回调接口，可将请求成功后要执行的程序写在其中
    if (httpRequest.readyState == 4 && httpRequest.status == 200) {//验证请求是否发送成功
      var json = JSON.parse(httpRequest.responseText);//获取到服务端返回的数据
      console.log(json);
      if(json['message'] == '提交成功'){
        alert('提交成功！')
      }else{
        alert('提交失败！')
      }
    }
  };
}